Ext.require(['*']);

document.write('<script type="text/javascript" src="Scripts/menu/operations.js"></script>');
document.write('<script type="text/javascript" src="Scripts/menu/accounting.js"></script>');
document.write('<script type="text/javascript" src="Scripts/menu/administration.js"></script>');
document.write('<script type="text/javascript" src="Scripts/menu/distribution.js"></script>');   
document.write('<script type="text/javascript" src="Scripts/menu/utilities.js"></script>');
document.write('<script type="text/javascript" src="Scripts/menu/reports.js"></script>');  



Ext.onReady(function () {

    var header = Ext.create('Ext.Panel', {        
        id: 'header',
        region: 'north',
        html: '<div id="header"><h1> TimeX Application</h1></div>',
        height: 30
    });

    var accordion = Ext.create('Ext.Panel', {
        region: 'west',
        margins: '5 0 5 5',
        split: true,
        width: 210,
        layout: 'accordion',
        items: [accounting, administration, distribution, operations, reports, utilities]
    });

    var view_main = Ext.create('Ext.Panel', {
                        id: 'vp_view_main',
                        region: 'center',
                        margins: '5 5 5 0',
                        cls: 'empty',
                        bodyStyle: 'background:#f1f1f1',
                        html: '<div id="dv_view_main"></div>'
                    });

    var viewport = Ext.create('Ext.Viewport', {
        layout: 'border',
        items: [header, accordion,view_main]
    });
});

function mainmenu() {
    var obj = new Object();

    obj.page_Page_Construction = '0';
    //======Dispatch======//
    obj.page_Dispatch_Screen = '2';
    obj.page_Drivers_Database = '3';
    //======Order Entry======//
    obj.page_Order_Entry = '1';    
    //==================//

    obj.view = function (key) {
        var url = '';
        if (key == obj.page_Dispatch_Screen) {
            url = 'Views/Dispatch/Dispatch_Screen.aspx';
        } else if (key == obj.page_Drivers_Database) {
            url = 'Views/Dispatch/Drivers_Database.aspx';
        } else if (key == obj.page_Order_Entry) {
            url = 'Views/Operations/OrderEntry.aspx';
        } else {
            url = 'Views/Page_Construction.aspx';
        }

        $.ajax({
            url: url,
            success: function (data) {
                $('#dv_view_main').html(data);
            }
        });
    }

    return obj;
}

var _mainmenu_ = new mainmenu();